//
//  SelectFactorySectionTableViewCell.m
//  Rail
//
//  Created by huyuchen on 2018/3/19.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "SelectFactorySectionTableViewCell.h"
#import "SelectFactorySectionView.h"

@interface SelectFactorySectionTableViewCell ()
@property (nonatomic, strong) SelectFactorySectionView *sectionView;
@end
@implementation SelectFactorySectionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self showBottomLineWithPaddingX:15 color:nil];
        [self setupSectionView];
    }
    return self;
}

- (void)setupSectionView {
    SelectFactorySectionView *view = [[SelectFactorySectionView alloc] init];
    self.sectionView = view;
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}

- (void)setModel:(SelectFactoryFoldCellModel *)model {
    _model = model;
    
    [self.sectionView switchArrowDirection:(model.belowCount > 0)];
    
    self.sectionView.titleLabel.text = ((FactoryTreeLineModel *)model.obj).line_name;
}

- (void)clickEvent {
    [self.sectionView switchArrowDirection:!(self.model.belowCount > 0)];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
